 DEFINE INPUT PARAMETER fi-table AS CHARACTER. 

/*
DEFINE VARIABLE fi-table AS CHARACTER.
fi-table = "mnd_det".
*/

CASE fi-table :

    WHEN "mnd_det" THEN
        RUN mnd_det.

    WHEN "pin_mstr" THEN
        RUN pin_mstr.
    
    WHEN "flh_mstr" THEN
        RUN flh_mstr.
    
    WHEN "mnt_det" THEN
        RUN mnt_det.

    OTHERWISE 
        RETURN.

END CASE.

PROCEDURE mnd_det :

FOR EACH db_from.mnd_det:

    FIND FIRST db_to.mnd_det WHERE db_to.mnd_det.mnd_nbr = db_from.mnd_det.mnd_nbr AND 
        db_to.mnd_det.mnd_select = db_from.mnd_det.mnd_select EXCLUSIVE-LOCK NO-ERROR.

    IF NOT AVAILABLE db_to.mnd_det THEN
        CREATE db_to.mnd_det.

    ASSIGN
        db_to.mnd_det.mnd_nbr    = db_from.mnd_det.mnd_nbr
        db_to.mnd_det.mnd_select = db_from.mnd_det.mnd_select
        db_to.mnd_det.mnd_label  = db_from.mnd_det.mnd_label
        db_to.mnd_det.mnd_exec   = db_from.mnd_det.mnd_exec
        db_to.mnd_det.mnd_fkey   = db_from.mnd_det.mnd_fkey
        db_to.mnd_det.mnd_help   = db_from.mnd_det.mnd_help
        db_to.mnd_det.mnd_canrun = db_from.mnd_det.mnd_canrun
        db_to.mnd_det.mnd_name   = db_from.mnd_det.mnd_name.

END.

END PROCEDURE.

PROCEDURE mnt_det :

    FOR EACH db_from.mnt_det:

        FIND FIRST db_to.mnt_det WHERE db_to.mnt_det.mnt_nbr = db_from.mnt_det.mnt_nbr AND 
            db_to.mnt_det.mnt_select = db_from.mnt_det.mnt_select AND 
            db_to.mnt_det.mnt_lang = db_from.mnt_det.mnt_lang  EXCLUSIVE-LOCK NO-ERROR.

        IF NOT AVAILABLE db_to.mnt_det THEN
            CREATE db_to.mnt_det.

        ASSIGN
            db_to.mnt_det.mnt_nbr    = db_from.mnt_det.mnt_nbr
            db_to.mnt_det.mnt_select = db_from.mnt_det.mnt_select
            db_to.mnt_det.mnt_lang  = db_from.mnt_det.mnt_lang
            db_to.mnt_det.mnt_label   = db_from.mnt_det.mnt_label.
	END.
	
END PROCEDURE.



PROCEDURE flh_mstr :

    FOR EACH db_from.flh_mstr:

        FIND FIRST db_to.flh_mstr WHERE db_to.flh_mstr.flh_field = db_from.flh_mstr.flh_field AND 
            db_to.flh_mstr.flh_call_pgm = db_from.flh_mstr.flh_call_pgm EXCLUSIVE-LOCK NO-ERROR.

        IF NOT AVAILABLE db_to.flh_mstr THEN
            CREATE db_to.flh_mstr.

        ASSIGN
            db_to.flh_mstr.flh_field      = db_from.flh_mstr.flh_field
            db_to.flh_mstr.flh_call_pgm   = db_from.flh_mstr.flh_call_pgm
            db_to.flh_mstr.flh_desc       = db_from.flh_mstr.flh_desc
            db_to.flh_mstr.flh_exec       = db_from.flh_mstr.flh_exec
            db_to.flh_mstr.flh_x          = db_from.flh_mstr.flh_x
            db_to.flh_mstr.flh_y          = db_from.flh_mstr.flh_y
            db_to.flh_mstr.flh_down       = db_from.flh_mstr.flh_down
            db_to.flh_mstr.flh_user1      = db_from.flh_mstr.flh_user1
            db_to.flh_mstr.flh_user2      = db_from.flh_mstr.flh_user2
            db_to.flh_mstr.flh__qadc01    = db_from.flh_mstr.flh__qadc01
            db_to.flh_mstr.flh_mod_userid = db_from.flh_mstr.flh_mod_userid
            db_to.flh_mstr.flh_mod_date   = db_from.flh_mstr.flh_mod_date
            .
    END.
END.


PROCEDURE pin_mstr :

/*     FOR EACH db_from.pin_mstr:                                                                                                */
/*                                                                                                                               */
/*         /*FIND FIRST db_to.pin_mstr WHERE db_to.pin_mstr.pin_product = db_from.pin_mstr.pin_product EXCLUSIVE-LOCK NO-ERROR.  */
/*                                                                                                                               */
/*         IF NOT AVAILABLE db_to.pin_mstr THEN*/                                                                                */
/*         CREATE db_to.pin_mstr.                                                                                                */
/*                                                                                                                               */
/*         ASSIGN                                                                                                                */
/*             db_to.pin_mstr.pin_product     = db_from.pin_mstr.pin_product.                                                    */
/*             db_to.pin_mstr.pin_desc        = db_from.pin_mstr.pin_desc.                                                       */
/*             db_to.pin_mstr.pin_hwm         = db_from.pin_mstr.pin_hwm.                                                        */
/*             db_to.pin_mstr.pin_control1    = db_from.pin_mstr.pin_control1.                                                   */
/*             db_to.pin_mstr.pin_control2    = db_from.pin_mstr.pin_control2.                                                   */
/*             db_to.pin_mstr.pin_control3    = db_from.pin_mstr.pin_control3.                                                   */
/*             db_to.pin_mstr.pin_control4    = db_from.pin_mstr.pin_control4.                                                   */
/*             db_to.pin_mstr.pin_control5    = db_from.pin_mstr.pin_control5.                                                   */
/*             db_to.pin_mstr.pin_inst_date   = db_from.pin_mstr.pin_inst_date.                                                  */
/*             db_to.pin_mstr.pin_user1       = db_from.pin_mstr.pin_user1.                                                      */
/*             db_to.pin_mstr.pin_user2       = db_from.pin_mstr.pin_user2.                                                      */
/*             db_to.pin_mstr.pin__qadc01     = db_from.pin_mstr.pin__qadc01.                                                    */
/*             db_to.pin_mstr.pin__qadi01     = db_from.pin_mstr.pin__qadi01.                                                    */
/*             db_to.pin_mstr.pin__qadd01     = db_from.pin_mstr.pin__qadd01.                                                    */
/*             db_to.pin_mstr.pin__qadl01     = db_from.pin_mstr.pin__qadl01.                                                    */
/*             db_to.pin_mstr.pin__qadt01     = db_from.pin_mstr.pin__qadt01.                                                    */
/*             db_to.pin_mstr.pin_control6    = db_from.pin_mstr.pin_control6.                                                   */
/*             db_to.pin_mstr.pin_inst_time   = db_from.pin_mstr.pin_inst_time.                                                  */
/*             db_to.pin_mstr.pin_mod_userid  = db_from.pin_mstr.pin_mod_userid.                                                 */
/*             db_to.pin_mstr.pin_mod_date    = db_from.pin_mstr.pin_mod_date.                                                   */
/*             db_to.pin_mstr.pin_aud_days    = db_from.pin_mstr.pin_aud_days.                                                   */
/*             db_to.pin_mstr.pin_aud_ddate   = db_from.pin_mstr.pin_aud_ddate.                                                  */
/*             db_to.pin_mstr.pin_aud_date    = db_from.pin_mstr.pin_aud_date.                                                   */
/*             db_to.pin_mstr.pin_aud_user    = db_from.pin_mstr.pin_aud_user.                                                   */
/*             db_to.pin_mstr.pin_aud_pswd    = db_from.pin_mstr.pin_aud_pswd.                                                   */
/*             db_to.pin_mstr.pin_aud_nbr     = db_from.pin_mstr.pin_aud_nbr.                                                    */
/*                                                                                                                               */
/*                                                                                                                               */
/*     END.                                                                                                                      */
	
END PROCEDURE.
